home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
-
- #define BUFFLEN 1024
-
- char buffer[BUFFLEN];
-
- void usage()
- {
- fprintf( stderr, "Usage: putmail user\n" );
- exit( 1 );
- }
-
-
- FILE *infile;
- FILE *outfile;
-
- int main( int argc, char **argv )
- {
- char *buff;
-
- if( argc!=2 ) usage();
- infile = stdin;
- sprintf( buffer, "<Mail$dir>.spool.mail.text.%s", argv[1] );
- if( ! (outfile=fopen(buffer,"a")) ) {
- fprintf( stderr, "unable to open mail box\n" );
- exit( 1 );
- }
- /* we do no file locking ! */
- buff = fgets( buffer, BUFFLEN-1, infile );
- if( memcmp( buffer, "From ", 5 ) ) {
- time_t atim;
-
- time( &atim );
- fprintf( outfile, "From %s", ctime( &atim ));
- }
-
- while( buff==buffer ) {
- fputs( buffer, outfile );
- buff = fgets( buffer, BUFFLEN-1, infile );
- }
- fprintf( outfile, "\n" );
- fclose( infile );
- fclose( outfile );
- return 0;
- }
-